package ACwing.P1BasicAlgorithm.qianzhuihe;

import java.util.Scanner;

/**
 * @Date : 2022/10/23
 * @Description:
 */
public class Pre {
    static final int N=100010;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int [] q = new int[N],s = new int[N];
        s[0]=0;
        for (int i = 1; i <= n; i++) {
            q[i]=sc.nextInt();
            s[i]=s[i-1]+q[i];
        }

        for (int i = 0; i < m; i++) {
            int l=sc.nextInt();
            int r=sc.nextInt();
            System.out.println(s[r]-s[l-1]);
        }
    }
}
